package com.example.controller;

import com.example.common.log.LogAnnotation;
import com.example.service.UserService;
import com.example.entity.User;
import com.example.req.UserReq;
import com.example.req.UserSaveReq;

import com.example.resp.Result;
import com.example.resp.PageResp;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping("/getList")
    @LogAnnotation(module = "用户模块", operation = "用户列表")
    public Result getList(UserReq userReq) {
        PageResp<User> list = userService.getList(userReq);
        return Result.success(list);
    }

    @PostMapping("/delete/{id}")
    public Result delete(@PathVariable Long id) {
        userService.delete(id);
        return Result.success();
    }

    @PostMapping("/save")
    public Result save(@RequestBody UserSaveReq req) {
        userService.save(req);
        return Result.success();
    }


}
